# mode =
# "w": 以写的方式打开文件, 覆盖写入
# a : 追加写入
with open("../../data/a.txt", mode="a", encoding="UTF-8") as file:
    file.write("java")
    file.write("\n")
    file.write("大数据")

# 将列表中的数据保存到文件中
info = ["001", "张三", 23, "男"]

with open("../../data/info.txt", mode="w", encoding="UTF-8") as file:
    # 循环将列表中的元素保存到文件
    for inf in info:
        file.write(str(inf))
        file.write("\t")

with open("../../data/info.txt", mode="a", encoding="UTF-8") as file:
    # 将列表中的元素全部转换成str
    info = [str(i) for i in info]
    # join:将一个列表拼接成一个字符串，和split功能相反
    info_str = "\t".join(info)
    file.write(info_str)
